package com.zh.springcloud.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer;
import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter;

/**
 * @Description: 配置资源服务器
 * @ClassName ResourceServerConfig
 * @date: 2021.10.26 20:22
 * @Author: zhanghang
 */
@Configuration
@EnableResourceServer // 开启资源服务
public class ResourceServerConfig extends ResourceServerConfigurerAdapter {


	@Override
	public void configure(HttpSecurity http) throws Exception {
		// csrf放行
		http.csrf().disable()
				.authorizeRequests()
				// 放行资源
				.anyRequest().authenticated()
				.and()
				.requestMatchers()
				.antMatchers("/user/**");
	}
}
